#include "splashscene.h"
#include <QTimer>
#include "recource.h"
#include "scene/mainscene.h"
#include "item/imageitem.h"
#include <QResource>
#include <QCoreApplication>
#include "scene/settingscene.h"
#include "scene/helpscene.h"
#include "view/promptview.h"
#include "mainwindow.h"
#include "scene/selscene.h"
#include "scene/gamescene.h"
#include "sound/GameSounds.h"
#include <QLocale>

SplashScene::SplashScene(QObject *parent):
    QGraphicsScene(parent)
{
    setSceneRect(0.0, 0.0, 360.0, 640.0);

    m_bgItem = new ImageItem(QImage(":/image/splash/splash.jpg"),
                             QRect(QPoint(0,0),QImage(":/image/splash/splash.jpg").size()));
    m_bgItem->setZValue(0.0);
    addItem(m_bgItem);
    QTimer::singleShot(1000,this,SLOT(Over()));
}

void SplashScene::Over()
{
   QLocale locale(QLocale::system());
   Recource::m_iLanguage = static_cast<int>(locale.language());
   if(Recource::m_iLanguage==QLocale::Chinese)
   {
       if(QLocale::China!=locale.country())
           Recource::m_iLanguage=255;
   }
   Recource::LoadImage();
   Recource::LoadData();

   Recource::m_mainscene = new MainScene(Recource::m_mainwindow);
   connect(Recource::m_mainscene,SIGNAL(showPrompt()),Recource::m_mainwindow,SLOT(ShowPrompt()));

   Recource::m_setscene = new SettingScene(Recource::m_mainwindow);

   Recource::m_helpscene = new HelpScene(Recource::m_mainwindow);

   Recource::m_selscene = new SelScene(Recource::m_mainwindow);

   Recource::m_gamescene = new GameScene(Recource::m_mainwindow);
   connect(Recource::m_gamescene,SIGNAL(showPause()),Recource::m_mainwindow,SLOT(ShowPause()));
   connect(Recource::m_gamescene,SIGNAL(over()),Recource::m_mainwindow,SLOT(GameOver()));

   QString path = QCoreApplication::applicationDirPath() + "\\Resources\\Image.rcc";
   path.replace("/","\\");

#ifdef Q_OS_SYMBIAN
   QResource::unregisterResource(path);
#endif

   Recource::m_gamesound = new GameSounds(Recource::m_mainwindow);

   Recource::SetMain();
}

